home *** CD-ROM | disk | FTP | other *** search
/ Symantec Visual Cafe for Java 2.5 / symantec-visual-cafe-2.5-database-dev-edition.iso / Visual Cafe Pro v1.0 / VISCAFE.BIN / VPOJAVA.DLL / SOURCE / QUITDIALOG < prev    next >
Encoding:
Text File  |  1997-06-19  |  2.0 KB  |  78 lines

  1. /*
  2.     A basic extension of the java.awt.Dialog class
  3.  */
  4.  
  5. import java.awt.*;
  6.  
  7. public class QuitDialog extends Dialog {
  8.     void yesButton_Clicked(Event event) {
  9.         getParent().handleEvent(new Event(this, Event.WINDOW_DESTROY, null));
  10.     }
  11.  
  12.     void noButton_Clicked(Event event) {
  13.         //{{CONNECTION
  14.         // Clicked from noButton Hide the Dialog
  15.         hide();
  16.         //}}
  17.     }
  18.  
  19.     public QuitDialog(Frame parent, boolean modal) {
  20.  
  21.         super(parent, modal);
  22.  
  23.         //{{INIT_CONTROLS
  24.         setLayout(null);
  25.         // addNotify();
  26.         resize(insets().left + insets().right + 337,insets().top + insets().bottom + 135);
  27.         yesButton = new java.awt.Button(" Yes ");
  28.         yesButton.reshape(insets().left + 72,insets().top + 80,79,22);
  29.         yesButton.setFont(new Font("Dialog", Font.BOLD, 12));
  30.         add(yesButton);
  31.         noButton = new java.awt.Button("  No  ");
  32.         noButton.reshape(insets().left + 185,insets().top + 80,79,22);
  33.         noButton.setFont(new Font("Dialog", Font.BOLD, 12));
  34.         add(noButton);
  35.         label1 = new java.awt.Label("Do you really want to quit?");
  36.         label1.reshape(insets().left + 78,insets().top + 33,180,23);
  37.         add(label1);
  38.         setTitle("A Basic Application - Quit");
  39.         setResizable(false);
  40.         //}}
  41.     }
  42.  
  43.     public QuitDialog(Frame parent, String title, boolean modal) {
  44.         this(parent, modal);
  45.         setTitle(title);
  46.     }
  47.  
  48.     public synchronized void show() {
  49.         Rectangle bounds = getParent().bounds();
  50.         Rectangle abounds = bounds();
  51.  
  52.         move(bounds.x + (bounds.width - abounds.width)/ 2,
  53.              bounds.y + (bounds.height - abounds.height)/2);
  54.  
  55.         super.show();
  56.     }
  57.  
  58.     public boolean handleEvent(Event event) {
  59.         if(event.id == Event.WINDOW_DESTROY) {
  60.             hide();
  61.             return true;
  62.         }
  63.         if (event.target == noButton && event.id == Event.ACTION_EVENT) {
  64.             noButton_Clicked(event);
  65.         }
  66.         if (event.target == yesButton && event.id == Event.ACTION_EVENT) {
  67.             yesButton_Clicked(event);
  68.         }
  69.         return super.handleEvent(event);
  70.     }
  71.  
  72.     //{{DECLARE_CONTROLS
  73.     java.awt.Button yesButton;
  74.     java.awt.Button noButton;
  75.     java.awt.Label label1;
  76.     //}}
  77. }
  78.